<?php
	@$pid = $_GET['pid'];
	@$act = $_GET['act'];
	if($pid != '' && $act == 'del')
	{
		$result = $exec_mysql->execute("select image, big_img from product where id = $pid", 0);
		while($row = mysql_fetch_array($result))
		{
			$img = $row['image'];
			$img_big = $row['big_img'];
		}
		unlink('../'.$img);
		unlink('../'.$img_big);
		$exec_mysql->execute("delete from product where id = $pid", 0);
	}
?>
<script type="text/javascript">
	function delPro(url){
		window.location = url;
	}
</script>
<table class="table-list" width="90%">
	<tr class="table-header"><td>STT</td><td>Code</td><td>Tên sản phẩm</td><td>Lượt xem</td><td>Sửa</td><td>Xóa</td></tr>
	<?php
        $result = $exec_mysql->execute("select id, code, name, view from product order by date_upload desc", 0);
		$no = 0;
		while($row = mysql_fetch_array($result))
		{
			$no++;
			echo '<tr>';
			echo '<td align="center">'.$no.'</td>';
			echo '<td>'.$row['code'].'</td>';
			echo '<td>'.$row['name'].'</td>';
			echo '<td align="center">'.$row['view'].'</td>';
			echo '<td align="center"><a href="admin_master_page.php?cmd=3.4&pid='.$row['id'].'&act=edit"><img src="img/ico_edit.png" title="Sửa" /></a></td>';
			echo '<td align="center"><a href="javascript:void()"><img src="img/ico_delete.png" title="Xóa" onclick="showConfirm(\'Xác nhận\', \'Bạn có chắc muốn xóa sản phẩm này không?\', \'delPro([admin_master_page.php?cmd=3.2&pid='.$row['id'].'&act=del])\')" /></a></td>';
			echo '</tr>';
		}
    ?>
</table>